using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.ConnectionEngine.SampleDeploymentManager.WizardPages
{
    public partial class WebSiteConfigPage : WizardPageBase
    {
        private const string APP_IIS_SITE = "appIISSite";
        private const string APP_POOL_NAME = "appPoolName";
        private const string APP_POOL_USER = "appPoolUser";
        private const string APP_POOL_PASS = "appPoolPass";
        private const string SP_ID = "serviceProviderID";

        public WebSiteConfigPage()
        {
            InitializeComponent();
        }

        public override void Activate(ref Dictionary<string, object> parameters)
        {
            base.Activate(ref parameters);

            if (!_parameters.ContainsKey(APP_IIS_SITE)) _parameters.Add(APP_IIS_SITE, "");
            if (!_parameters.ContainsKey(APP_POOL_NAME)) _parameters.Add(APP_POOL_NAME, "");
            if (!_parameters.ContainsKey(APP_POOL_USER)) _parameters.Add(APP_POOL_USER, "");
            if (!_parameters.ContainsKey(APP_POOL_PASS)) _parameters.Add(APP_POOL_PASS, "");
            if (!_parameters.ContainsKey(SP_ID)) _parameters.Add(SP_ID, "");

            if (_parameters.ContainsKey(APP_IIS_SITE)) txtAppName.Text = _parameters[APP_IIS_SITE].ToString();
            if (_parameters.ContainsKey(APP_POOL_NAME)) txtAppPoolName.Text = _parameters[APP_POOL_NAME].ToString();
            if (_parameters.ContainsKey(SP_ID)) txtSPID.Text = _parameters[SP_ID].ToString();
        }

        private void txtAppName_Leave(object sender, EventArgs e)
        {
            if (_parameters.ContainsKey(APP_IIS_SITE)) _parameters.Remove(APP_IIS_SITE);
            _parameters.Add(APP_IIS_SITE, txtAppName.Text);
        }

        private void txtAppPoolName_Leave(object sender, EventArgs e)
        {
            if (_parameters.ContainsKey(APP_POOL_NAME)) _parameters.Remove(APP_POOL_NAME);
            _parameters.Add(APP_POOL_NAME, txtAppPoolName.Text);
        }

        private void txtSPID_Leave(object sender, EventArgs e)
        {
            if (_parameters.ContainsKey(SP_ID)) _parameters.Remove(SP_ID);
            _parameters.Add(SP_ID, txtSPID.Text);
        }
    }
}
